Skip to content

Regression in loc.setitem raising ValueError with unordered MultiIndex columns and scalar indexer #39071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 10, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 9, 2021

@jbrockmendel Would it be faster to use arange too in the line above of my fix instead of Index?

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Regression Functionality that used to work in a prior pandas version labels Jan 9, 2021
@@ -1685,6 +1685,15 @@ def test_getitem_interval_index_partial_indexing(self):
res = df.loc[:, 0.5]
tm.assert_series_equal(res, expected)

@pytest.mark.parametrize("indexer", ["A", ["A"]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the other 3 cases from OP that 'work fine' (2 x slice and a sorted case). ok to have another test if helpful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, worked through parametrization

@jreback jreback added this to the 1.2.1 milestone Jan 9, 2021
@jbrockmendel
Copy link
Member

Would it be faster to use arange too in the line above of my fix instead of Index?

I think you're right, yes

@phofl
Copy link
Member Author

phofl commented Jan 9, 2021

Changed it then

@jreback
Copy link
Contributor

jreback commented Jan 10, 2021

lgtm. will merge / backport on green.

@phofl
Copy link
Member Author

phofl commented Jan 10, 2021

Merged master again to fix benchmarks, will ping on green

@phofl
Copy link
Member Author

phofl commented Jan 10, 2021

@jreback green

@jreback jreback merged commit f6a4f29 into pandas-dev:master Jan 10, 2021
@jreback
Copy link
Contributor

jreback commented Jan 10, 2021

this @phofl

@jreback
Copy link
Contributor

jreback commented Jan 10, 2021

@meeseeksdev backport 1.2.x

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 10, 2021
…Error with unordered MultiIndex columns and scalar indexer
@phofl phofl deleted the 38601 branch January 10, 2021 04:02
simonjayhawkins pushed a commit that referenced this pull request Jan 11, 2021
… unordered MultiIndex columns and scalar indexer (#39084)

Co-authored-by: patrick <[email protected]>
@simonjayhawkins
Copy link
Member

Would it be faster to use arange too in the line above of my fix instead of Index?

I think you're right, yes

#32477 (comment)

@phofl
Copy link
Member Author

phofl commented Jan 11, 2021

Interesting, but should not matter?

@phofl
Copy link
Member Author

phofl commented Jan 11, 2021

I don't think this makes a difference, we are always looping over the result as far as I can see.

luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
…x columns and scalar indexer (pandas-dev#39071)

* Regression in loc.setitem raising ValueError with unordered MultiIndex columns and scalar indexer

* Add tests

* Improve performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: loc assignment with a numpy array fails when MultiIndex columns are not sorted
4 participants